const app = getApp()
Page({
  data: {
    loadingHidden: false,
    arrangeList:{},
    weekList:{},
    hourpartGroup:{},
    arrangeRow:[],
    ishavedata:false,//是否有课表数据
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: "课表"
    })
    var that=this;
    that.gettimetable();
  },

  onReady: function () {

  },
  onShow: function () {

  },

  onHide: function () {

  },
  onUnload: function () {

  },

  onPullDownRefresh: function () {

  },

  onReachBottom: function () {

  },

  onShareAppMessage: function () {

  },
//课表数据
gettimetable: function () {
  var class_id="";
    if (app.globalData.bindInfo) {
      if (app.globalData.bindInfo.user_type==3){
        class_id = app.globalData.bindInfo.dept_id;
      }
      if (app.globalData.bindInfo.user_type == 1) {
        class_id = app.globalData.bindInfo.classmaster;//班主任
      }
    }else{
      wx.redirectTo({
        url: '../binding/binding'
      })
    }
    var link = app.globalData.schlink;//学校域名
    var openid = app.globalData.openid;
    var that = this;
    wx.request({
      url: getApp().globalData.baseUrl + 'classArrange',
      method: "GET",
      data: {
        class_id: class_id,
        openid: openid,
        link: link
      },
      header: {
        "content-type": "application/x-www-form-urlencoded"
      },
      success: function (res) {
        that.setData({
          loadingHidden: true,
        });
        if (res.data.code == 200) {
          var result = res.data.data;
        
          if (result.weekList.length >0){
            that.setData({ weekList: result.weekList });
          }else{
            that.setData({ weekList: false });
          }
          if (result.hourpartGroup){
            if (Object.keys(result.hourpartGroup).length >0){
              that.setData({ ishavedata: true });
            }
            that.setData({ hourpartGroup: result.hourpartGroup});
          }else{
            that.setData({ hourpartGroup: false });
          }
        }else{
        //失败
          that.setData({ weekList: false });
          that.setData({ hourpartGroup: false});
        }
      }
    })
  },
})